package com.xindaoapp.happypet.utils;

import android.app.Activity;
import android.content.Intent;

import com.xindaoapp.happypet.bean.PetInfo;
import com.xindaoapp.happypet.bean.User;
import com.xindaoapp.happypet.ui.LoginActivity;

/**
 * 静态的变量
 * 
 * @author chenghao
 * 
 */
public class CommonParameter {
    /**
     * 是否加载图片<br/>
     * <br/>
     * true：<br/>
     * 1.wifi开关打开，并且是wifi网络，可以加载图片<br/>
     * 2.wifi开关关闭，可以加载网络<br/>
     * false：wifi开关打开，是3G网络
     */
    // public static boolean isDisPlayImage = true;

    /** 屏幕宽度，启动时候初始化 */
    public static int sScreenWidth;
    /** 屏幕高度，启动时候初始化 */
    public static int sScreenHeight;

    /**
     * 是否加载图片 <br/>
     * true 打开<br/>
     * false 关闭
     */
    public static boolean isLoadImg = true;

    public static class UserState {
        private static User sUser;

        private static PetInfo sPetInfo;

        public static void setUser(User user) {
            sUser = user;
        }

        public static PetInfo getPetInfo() {
            return sPetInfo;
        }

        public static void setPetInfo(PetInfo petInfo) {
            UserState.sPetInfo = petInfo;
        }

        public static User getUser() {
            return sUser;
        }

        public static Boolean isLogged() {
            return sUser == null ? false : true;
        }

        public static String getUserUid() {
            return sUser == null ? "" : sUser.uid;
        }

        /**
         * onActivityResult()<br/>
         * requestCode 500
         * 
         * @param context
         * @return
         */
        public static Boolean isLogged(Activity context) {
            if (sUser == null) {
                Intent intent = new Intent(context, LoginActivity.class);
                context.startActivityForResult(intent, Constants.REQUESTCODE_LOGIN);
                return false;
            }
            return true;
        }
    }

    /**
     * 登录成功之后的用户资料
     */
    // public static User sUser;

}
